//
//  ServerItemCell.m
//  SalonManage
//
//  Created by tim on 2017/7/30.
//  Copyright © 2017年 lmtt. All rights reserved.
//

#import "ServerItemCell.h"
#import "UIImage+Color.h"

@interface ServerItemCell()
@property (nonatomic,strong) UIImageView * serimageView;//项目图片
@property (nonatomic,strong) UILabel * titleLabel;//标题
@property (nonatomic,strong) UILabel * priceLabel;//价格

@property (nonatomic,strong) LMButton * delBtn;

@end
@implementation ServerItemCell

#pragma mark - 生命周期

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.serimageView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.priceLabel];
        [self.contentView addSubview:self.delBtn];
        self.backgroundColor = [UIColor whiteColor];
        
        [self setLayout];
    }
    return self;
}

#pragma mark - Private
#pragma mark - 数据源和代理方法
#pragma mark - UIView -> 下面放继承自UIView的方法

- (void)setLayout {
    self.serimageView.whc_TopSpace(HGADPT(20)).whc_LeftSpace(HGADPT(30)).whc_Width(HGADPT(150)).whc_Height(HGADPT(120));
    self.titleLabel.whc_TopSpace(HGADPT(30)).whc_LeftSpaceToView(HGADPT(30), self.serimageView).whc_RightSpace(HGADPT(200)).whc_Height(HGADPT(30));
    self.priceLabel.whc_BottomSpace(HGADPT(30)).whc_LeftSpaceToView(HGADPT(30), self.serimageView).whc_RightSpace(HGADPT(200)).whc_Height(HGADPT(30));
    
    self.delBtn.whc_RightSpace(HGADPT(30)).whc_Width(HGADPT(160)).whc_Height(HGADPT(60)).whc_CenterYToView(0, self.serimageView);

    
}


+ (instancetype)serverItemCellWithTableView:(UITableView *)tableView{
    
    static NSString *cellID = @"ServerItemCell";
    ServerItemCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    if (cell == nil) {
        cell = [[ServerItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

-(UIImageView *)serimageView{
    if (_serimageView == nil) {
        _serimageView = [[UIImageView alloc]init];
        _serimageView.image = [UIImage lm_imageWithColor:kRandColor];
    }
    return _serimageView;
}

-(UILabel *)titleLabel{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.text = @"理发";
        _titleLabel.font = _kFontMain;
        _titleLabel.textColor = kColor3C3C3C;
    }
    return _titleLabel;
}

-(UILabel *)priceLabel{
    if (_priceLabel == nil) {
        _priceLabel = [[UILabel alloc]init];
        _priceLabel.text = @"￥200";
        _priceLabel.font = _kFontMain;
        _priceLabel.textColor = kColor3C3C3C;
        
    }
    return _priceLabel;
}

-(LMButton *)delBtn{
    if (_delBtn == nil) {
        _delBtn = [LMButton lm_buttonWithType:LMButtonTypeMove title:@"删除"];
        _delBtn.titleLabel.font= _kFontMain;
    }
    return _delBtn;
}

@end
